<script type="text/javascript" src="/js/boxy/js/jquery.boxy.js"></script>
<link href="/js/boxy/css/boxy.css" media="screen" rel="stylesheet" type="text/css" >  
<script type="text/javascript">
      $(function() {
            window.alert = Boxy.alert;
            window.confirm = Boxy.confirm;
      });

<?php if ($this->conse == 1) { ?>
            Boxy.alert('添加成功！');
            window.setTimeout("location.href = '/admini/todotask/index'", 2000);
<?php } ?>
</script>
<style>
      .button {
            display: inline-block;
            outline: none;
            cursor: pointer;
            text-align: center;
            text-decoration: none;
            font: 14px/100% Arial, Helvetica, sans-serif;
            padding: .5em 2em .55em;
            text-shadow: 0 1px 1px rgba(0,0,0,.3);
            -webkit-border-radius: .5em; 
            -moz-border-radius: .5em;
            border-radius: .5em;
            -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
            -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
            box-shadow: 0 1px 2px rgba(0,0,0,.2);
            color: #fef4e9;
            border: solid 1px #da7c0c;
            background: #f78d1d;
            background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));
            background: -moz-linear-gradient(top,  #faa51a,  #f47a20);
            filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20');
      }
      .button:hover {
            text-decoration: none;
            background: #f47c20;
            background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
            background: -moz-linear-gradient(top,  #f88e11,  #f06015);
            filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
      }
      .button:active {
            position: relative;
            top: 1px;
            color: #fcd3a5;
            background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
            background: -moz-linear-gradient(top,  #f47a20,  #faa51a);
            filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
      }
</style>
<?php if (!($this->objectId && $this->objectType)) { ?>
      <div id="form">
            <form action="" method="post" id="ingform">     
                  <div class="rukutop">
                        <div class="rktopleft" style="width:1000px;">
                              <div class="rukushuru">
                                    <table>
                                          <tr>
                                                <td  colspan="2" align="center">添加待办事项</td>
                                          </tr>

                                    </table>
                              </div>
                              <div class="rukushuru" style="color:#c00;padding:8px 0;width: 400px;margin-left: 10px;" id="userRemark">
                              </div>
                        </div>
                        <div class="rktopright">
                              <div class="rukuxinfo"><p></p></div>
                              <div class="kuwei"></div>
                        </div>
                  </div>
                  <div class="rukunr">
                        <div style="width:800px;font-size:14px;padding: 20px;">
                              <div>
                                    <div class="rk1z">
                                          <table>
                                                <tr>
                                                      <td width="50%" >预计日期：</td>
                                                      <td>
                                                            <input type="hidden" id="starttime" name="starttime" value="<?php echo $this->starttime ? $this->starttime : ""; ?>"/>
                                                            <div class="time" style="padding:6px 5px;border:#ccc solid 1px;width: 200px">
                                                                  <!--点击后悬停样式为：<div class="timeselect t_on">-->
                                                                  <div class="timeselect"  id="stime">
                                                                        <span id="stimeval"><?php echo $this->starttime ? $this->starttime : date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); ?></span><i></i>
                                                                  </div>
                                                                  <div class="timeslelctbox">
                                                                        <!---时间插件放此DIV-->
                                                                  </div>
                                                            </div>
                                                      </td>
                                                </tr>
                                                <tr>
                                                      <td class="rkz">事项类型：</td>
                                                      <td>
                                                            <input id="object-Type" type="hidden" value="<?= $this->objectType ?>" />
                                                            <input id="obj-id" type="hidden" value="<?= $this->objectId ?>" />
                                                            <select class="input3 w200 required" id="objectType" name="objectType" >
                                                                  <?php foreach ($this->objtype as $key => $val) { ?>
                                                                        <option value='<?= $val->id ?>'><?= $val->name ?></option>
                                                                  <?php } ?>
                                                            </select>
                                                      </td>
                                                </tr>
                                                <tr>
                                                      <td class="rkz" id="hanzi">关联单号：</td>
                                                      <td><input class="input3 w200" id="objectid" name="objectid" required="" style="width:195px;" value="<?= $this->objectId ?>" /><span id="tishi"></span></td>
                                                </tr>
                                                <tr>
                                                      <td class="rkz">优先级别：</td>
                                                      <td>
                                                            <select id="priority" name="priority" class="input3 w200">
                                                                  <option value="1">一般</option>
                                                                  <option value="2">较低</option>
                                                                  <option value="3">较高</option>
                                                                  <option value="3">最高</option>
                                                            </select>
                                                      </td>
                                                </tr>    
                                                <tr>
                                                      <td class="rkz">名称：</td>
                                                      <td><input class="input3 w600 required" required="" name="title" id="title"  value =""/></td>
                                                </tr>
                                                <tr id="qdremark">
                                                      <td class="rkz">内容：</td>
                                                      <td><textarea name="content" id="content" required="" class="textarea w600"></textarea>
                                                      </td>
                                                </tr>
                                                <tr>
                                                      <td class="rkz">指派给：</td>
                                                      <td style="padding-top:1px;">
                                                            <select id="distribut" class="input3 w200" name="distribut" style="font-size: 14px; line-height: 24px;">
                                                            <?php
                                                            foreach ($this->worker as $value) {
                                                                  echo "<option value={$value->nikename}>" . $value->nikename . "</option>";
                                                            }
                                                            ?>
                                                      </select>
                                                      </td>
                                                </tr>
                                                <tr >
                                                      <td class="rkz">状态：</td>
                                                      <td>
                                                            <select id="objstatus" name="objstatus" class="input3 w200">
                                                                  <option value="1">未开始</option>
                                                                  <option value="2">进行中</option>
                                                                  <option value="3">已完成</option>
                                                            </select>
                                                      </td>
                                                </tr>
                                                <tr>
                                                      <td class="rkz"></td>
                                                      <td><input type="submit" class="button" id="objsubmit" value="提交">
                                                            <input type="button" style="margin-left:30px;" class="button" value="返回" onclick="window.history.back()" >
                                                      </td>
                                                </tr>
                                          </table>
                                    </div>
                              </div>
                        </div>
                        <hr style="margin-left:-20px;">
                  </div>
            </form>
      </div>
<?php } ?>
<?php if ($this->objectId && $this->objectType) { ?>
<meta charset="utf-8"/>
<link href="/admins/css/adminshare.css" media="screen" rel="stylesheet" type="text/css" >
<link href="/js/boxy/css/boxy.css" media="screen" rel="stylesheet" type="text/css" >
<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/admins/js/jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="/js/messages_cn.js"></script>
<script type="text/javascript" src="/js/uuch.js"></script>



<div class="tanchuang" style="border:0px; box-shadow: 0 0 0px #ffffff;background: #fff;font-size: 12px;">
      <div class="nui-msgbox-hd" style="border:0px;background: #fff;"></div>
                  <form method="post" action="/admini/todotask/add/" id="form2">
                        <table style="margin:1px 30px 0px 30px;font-size: 13px;">
                              <tr>
                                    <td width="20%" >预计日期：</td>
                                    <td>
                                          <input type="hidden" id="starttime" name="starttime" value="<?php echo $this->starttime ? $this->starttime : ""; ?>"/>
                                          <div class="time" style="padding:6px 5px;border:#ccc solid 1px;width: 200px">
                                                <!--点击后悬停样式为：<div class="timeselect t_on">-->
                                                <div class="timeselect"  id="todostime">
                                                      <span id="stimeval"><?php echo $this->starttime ? $this->starttime : date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); ?></span><i></i>
                                                </div>
                                                <div class="timeslelctbox">
                                                      <!---时间插件放此DIV-->
                                                </div>
                                          </div>
                                    </td>
                              </tr>
                              <tr>
                              <input name="objectType" type="hidden" value="<?= $this->objectType ?>" />
                              <input name="objectid" type="hidden" value="<?= $this->objectId ?>" />
                              <td class="rkz">优先级别：</td>
                              <td>
                                    <select name="priority" class="input3 w200">
                                          <option value="1">一般</option>
                                          <option value="2">较低</option>
                                          <option value="3">较高</option>
                                          <option value="3">最高</option>
                                    </select>
                              </td>
                              </tr>    
                              <tr>
                                    <td class="rkz">名称：</td>
                                    <td><input class="input3 w200 required" required="" name="title" id="title"  value =""/></td>
                              </tr>
                              <tr id="qdremark">
                                    <td class="rkz">内容：</td>
                                    <td style="padding-top:1px;"><textarea name="content" id="content" required="" class="textarea w300"></textarea>
                                    </td>
                              </tr>
                              <tr>
                                    <td class="rkz">指派给：</td>
                                    <td style="padding-top:1px;">
                                          <select id="distribut" class="input3 w200" name="distribut" style="font-size: 14px; line-height: 24px;">
                                          <?php
                                          foreach ($this->worker as $value) {
                                                echo "<option value={$value->nikename}>" . $value->nikename . "</option>";
                                          }
                                          ?>
                                    </select>
                                    </td>
                              </tr>
                              <tr >
                                    <td class="rkz">状态：</td>
                                    <td>
                                          <select id="objstatus" name="objstatus" class="input3 w200">
                                                <option value="1">未开始</option>
                                                <option value="2">进行中</option>
                                                <option value="3">已完成</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td class="rkz"></td>
                                    <td><input type="submit" class="button" id="objsubmit" value="提交">
                                    </td>
                              </tr>
                        </table>
                  </form>
                  <div id="pointtrack">
                        <div id="tracktable">
                              <?php
                              if ($this->objlist) {
                                    echo'<div style="font-size:14px;padding: 0px;">该订单的其他待办事项：</div>';
                                    ?>
                                    <div class="biaotbody">
                                          <table style="font-size: 13px;" >
                                                <tr>
                                                      <th class="li10" style="text-align:center">
                                                            日期
                                                      </th>
                                                      <th class="li6" >
                                                            创建人
                                                      </th>
                                                      <th class="li10">
                                                            标题
                                                      </th>
                                                      <th class="li6" >
                                                            状态
                                                      </th>
                                                </tr>
                                          </table>
                                    </div>
                              <div class="table operatortrackcontent" style="overflow:auto;">
                                                <table style="font-size: 13px;">
                                    <?php
                                    foreach ($this->objlist as $key => $Item) {
                                          if ($key > 2)
                                                break;
                                          ?>
                                                      <tr>
                                                            <td class="li10" align="center"><?= $Item->dateCreated ?></td>
                                                            <td class="li6">
                                                                  <?= $Item->creator//$Item->UserName?$Item->UserName->nikename:''  ?>
                                                            </td>
                                                            <td class="li10"><?php echo $Item->title; ?></td>
                                                            <td class="li6" ><?php echo $Item->ObjectStatus; ?>
                                                            </td>
                                                      </tr>
                                                
                                          <?php
                                    }
                              } else {
                                    echo '<div class="tablebox"></div>';
                              }
                              ?>
                                                      </table>
                                          </div>
                        </div>
                  </div>
      </div>
<?php } ?>
<script>
      $(document).ready(function() {
            $('form').validate();
            $("#distribut").find("option[value='<?php echo Uuch_Util::getUserNikeName(); ?>']").attr("selected","true");
            $("#todostime").click(function() {
                  $(this).attr("class", "timeselect t_on");
                  WdatePicker({el: 'stimeval', vel: 'starttime', onpicked: function() {
                              $("#todostime,#etime").attr("class", "timeselect");
                              $(".soubox #timescope").val("");
                        }});
            });
            var objectType = $('#object-Type').val();
            if (objectType) {
                  $("#objectType option[value =" + objectType + "]").attr("selected", true);
            } else {
                  $("#objectType option[value = 3]").attr("selected", true);
                  $("#objectid").attr("style", "display:none;");
                  $("#hanzi").attr("style", "display:none;");
                  $("#objectid").val("0");
            }
            $("#objectType").change(function() {
                  if ($('#objectType').val() == 3) {
                        $("#objectid").attr("style", "display:none;");
                        $("#hanzi").attr("style", "display:none;");
                        $("#objectid").val("0");
                        $("#tishi").html("");
                  } else {
                        $("#objectid").attr("style", "display:block;");
                        $("#hanzi").attr("style", "display:block;");
                        $("#objectid").val("");
                  }
            });
            $("#objectid").change(function() {
                  $("#tishi").html("");
                  $.post(
                          '/admini/todotask/check/id/' + $("#objectId").val(),
                          {
                                objectId: $("#objectid").val(),
                                objectType: $("#objectType").val()
                          },
                  function(data) {
                        if(data == 0)
                        {
                              $("#tishi").html("<p style='color:red'>无此单号！</p>");
                              $("#objectid").val("");
                        }
                  });
            });
            $("#objsubmit").click(function(){
                 window.parent.$(".nui-msgbox-close").click();
            });
      });
</script>
